package com.ikingtech.framework.sdk.tenant.api;

import com.ikingtech.framework.sdk.core.response.R;
import com.ikingtech.framework.sdk.tenant.model.TenantDTO;
import com.ikingtech.framework.sdk.tenant.model.TenantQueryParamDTO;
import com.ikingtech.framework.sdk.web.annotation.GetRequest;
import com.ikingtech.framework.sdk.web.annotation.PostRequest;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author tie yan
 */
public interface TenantApi {

    @PostRequest(order = 1, value = "/add", summary = "新增", description = "新增，新增成功后返回编号。")
    R<String> add(@Parameter(name = "tenant", description = "租户信息")
                  @RequestBody TenantDTO tenant);

    @PostRequest(order = 2, value = "/delete", summary = "删除", description = "删除。")
    R<Object> delete(@Parameter(name = "tenantCode", description = "租户标识")
                     @RequestBody String tenantCode);

    @PostRequest(order = 3, value = "/update", summary = "更新", description = "更新。")
    R<Object> update(@Parameter(name = "tenant", description = "租户信息")
                     @RequestBody TenantDTO tenant);

    @PostRequest(order = 4, value = "/list/page", summary = "分页查询", description = "分页查询，没有查询结果时返回空列表。")
    R<List<TenantDTO>> page(@Parameter(name = "queryParam", description = "查询条件")
                            @RequestBody TenantQueryParamDTO queryParam);

    @PostRequest(order = 6, value = "/detail/id", summary = "查询详情", description = "查询详情，数据不存在时仍然返回成功,数据为null。")
    R<TenantDTO> detail(@Parameter(name = "id", description = "编号")
                        @RequestBody String id);

    @PostRequest(order = 7, value = "/detail/code", summary = "查询租户(租户标识)", description = "查询租户(租户标识)，指定的数据不存在时仍然返回成功,数据为null。")
    R<TenantDTO> getByCode(@Parameter(name = "code", description = "租户标识")
                           @RequestBody String code);

    @PostRequest(order = 7, value = "/detail/login-user", summary = "查询租户(租户标识)", description = "查询租户(租户标识)，指定的数据不存在时仍然返回成功,数据为null。")
    R<TenantDTO> getByLoginUser();

    @PostRequest(order = 7, value = "/list/login-user", summary = "查询租户(登录用户)", description = "查询租户(登录用户)，指定的数据不存在时返回空列表。")
    R<List<TenantDTO>> listByLoginUser();

    @GetRequest(value = "/retry", summary = "重试", description = "重新初始化一次")
    R<Object> retry(@Parameter(name = "tenantId", description = "租户id") @RequestParam("tenantId") String tenantId);
}
